Skip to content

feat(logs): --format json and relative --since/--until shortcuts - #552

Merged
Paveltarno merged 4 commits into
mainfrom
feat/logs-output-format
Jun 28, 2026
Merged

feat(logs): --format json and relative --since/--until shortcuts#552
Paveltarno merged 4 commits into
mainfrom
feat/logs-output-format

Conversation

@ImriKochWix

@ImriKochWix ImriKochWix commented Jun 24, 2026

Copy link
Copy Markdown
Contributor

Note

Description

Enhances the base44 logs command with two ergonomic improvements: a --json flag for clean, machine-readable output that's safe to pipe to tools like jq, and relative time shorthands (e.g. 1h, 30m, 2d) for the --since and --until options. These make scripting against function logs and querying recent activity much easier.

Related Issue

None

Type of Change

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • Documentation update
  • Refactoring (no functional changes)
  • Other (please describe):

Changes Made

  • Added a --json flag to base44 logs that emits the log entries as formatted JSON to stdout and suppresses the "Fetched logs" outro message, keeping stdout clean for piping to jq.
  • Extended normalizeDatetime to accept relative time shorthands via the ms library, so --since 1h, --since 30m, --since 2d, etc. resolve to an absolute ISO timestamp; ISO datetimes continue to work as before.
  • Updated the --since / --until --help descriptions to document the relative shorthand syntax.
  • Added the ms runtime dependency and @types/ms types (bundled per the zero-dependency distribution model).
  • Added tests covering --json output validity and relative --since shortcuts.

Testing

  • I have tested these changes locally
  • I have added/updated tests as needed
  • All tests pass (npm test)

Checklist

  • My code follows the project's style guidelines
  • I have performed a self-review of my own code
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation (if applicable)
  • My changes generate no new warnings
  • I have updated docs/ (AGENTS.md) if I made architectural changes

Additional Notes

The --level option remains hidden in --help. The new dependencies (ms, @types/ms) are added to devDependencies in line with the project's zero-dependency bundling model.


🤖 Generated by Claude | 2026-06-28 06:24 UTC | 22d0e10

- --format json outputs clean JSON (no UI chrome) for piping to jq etc.
- --since/--until now accept relative shorthands: 1h, 30m, 2d
- Suppress clack intro/outro when --format json via isRawOutputMode()

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@github-actions

github-actions Bot commented Jun 24, 2026

Copy link
Copy Markdown
Contributor

🚀 Package Preview Available!


Install this PR's preview build with npm:

npm i @base44-preview/cli@0.0.56-pr.552.22d0e10

Prefer not to change any import paths? Install using npm alias so your code still imports base44:

npm i "base44@npm:@base44-preview/cli@0.0.56-pr.552.22d0e10"

Or add it to your package.json dependencies:

{
  "dependencies": {
    "base44": "npm:@base44-preview/cli@0.0.56-pr.552.22d0e10"
  }
}

Preview published to npm registry — try new features instantly!

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>

private isRawOutputMode(): boolean {
return (this.opts() as Record<string, unknown>).format === "json";
}

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since we just added --format to the logs command i don't think it mkaes sense to add this check to the global Base44Command, can we resolve it on the specific command?

limit?: string;
order?: string;
json?: boolean;
format?: "text" | "json";

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why did you decide to go with --format json and not just --json?
since the default is already "text" no one will write --format text

? Number(rel[1]) * 3_600_000
: Number(rel[1]) * 86_400_000;
return new Date(Date.now() - ms).toISOString();
}

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

consider using a library that already solves this?
https://www.npmjs.com/package/ms maybe?

@kfirstri kfirstri left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

like the new flags, got some questions :)

ImriKochWix and others added 2 commits June 24, 2026 15:18
- Replace --format json|text with --json boolean flag
- Use ms library for relative time parsing in --since/--until
- Revert isRawOutputMode() from Base44Command (piping already sets isNonInteractive)

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>

@Paveltarno Paveltarno left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@Paveltarno
Paveltarno merged commit d42c399 into main Jun 28, 2026
13 checks passed
@Paveltarno
Paveltarno deleted the feat/logs-output-format branch June 28, 2026 08:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants